﻿using System;
using System.Windows.Input;
using NUnit.Framework;
using Present.Commands.Async.Actions;
using Present.Commands.Decorators;
using Present.Commands.Fluent;
using Rhino.Mocks;

namespace Present.Commands.Tests.Fluent
{
    [TestFixture]
    public class ScheduledCommandBuilderTestCase : TestCase
    {
        private IAsyncAction action;
        private ScheduledCommandBuilder<ICommand, object> builder;
        private ICommand command;

        public override void Setup()
        {
            base.Setup();
            command = MockRepository.GenerateStub<ICommand>();
            builder = new ScheduledCommandBuilder<ICommand, object>(command);
        }

        [Test]
        public void ExecuteBuiltCommand()
        {
            builder.Execute(null);
            command.AssertWasCalled(x=>x.Execute(null));
        }

        [Test]
        public void ScheduleIsSet()
        {
            var scheduled = (ScheduledCommandDecorator<ICommand>)command.Schedule().Every(TimeSpan.FromMinutes(1));
            Assert.IsNotNull(scheduled.Schedule);
        }

      

        [Test]
        public void CanBeCastToCommand()
        {
            Assert.IsInstanceOf<ScheduledCommandDecorator<ICommand>>((ScheduledCommandDecorator<ICommand>)builder);
        }

    }
}
